-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-76595: Add note on PyCapsule_Import
behavior
#134022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
gh-76595: Add note on PyCapsule_Import
behavior
#134022
Conversation
There's a PR (pythonGH-6898) which changes this behavior (to be less surprising, I believe), but this seems to have stalled. See: python#76595 See: python#6898
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should split up the note. The behavior regarding attribute lookups should go in the canonical description of the function, and then the gotcha about imports should be in the note.
Doc/c-api/capsule.rst
Outdated
@@ -108,6 +108,14 @@ Refer to :ref:`using-capsules` for more information on using these objects. | |||
Return the capsule's internal *pointer* on success. On failure, set an | |||
exception and return ``NULL``. | |||
|
|||
.. note:: | |||
|
|||
:c:func:`PyCapsule_Import` splits *name* on the ``.`` character, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already know that it's PyCapsule_Import
:
:c:func:`PyCapsule_Import` splits *name* on the ``.`` character, and | |
This function splits *name* on the ``.`` character, and |
Doc/c-api/capsule.rst
Outdated
imports the first element. It then processes further elements using | ||
attribute lookups. As a result, if *name* points to an attribute in | ||
some submodule or subpackage, this submodule or subpackage must be | ||
previously imported using other means (e.g. by using :c:func:`PyImport_ImportModule`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously imported using other means (e.g. by using :c:func:`PyImport_ImportModule`). | |
previously imported using other means (for example, by using :c:func:`PyImport_ImportModule`). |
Also needs to be wrapped.
Thanks for the feedback. I tried to handle both of the requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this. Someone else is free to nitpick the wording here.
I was somewhat surprised by this behavior recently, so thought it'd be useful to have a note in the docs.
There's a PR (GH-6898) which changes this behavior (to be less surprising, I believe), but this seems to have stalled.
See: #76595
See: #6898
📚 Documentation preview 📚: https://cpython-previews--134022.org.readthedocs.build/en/134022/c-api/capsule.html#c.PyCapsule_Import